// 
// Bachelor of Software Engineering
// Media Design School
// Auckland
// New Zealand
//
// (c) 2005 - 2014 Media Design School
//
// File Name	: ShowStack.cpp
// Desrciption	: CShowStack implementation file.
// Author(s)	: Hayden Asplet.
// Mail			: hayden.asplet@mediadesignschool.com
//

// PCH
#include "SolitaireStd.h"

// Library Includes

// This Include
#include "ShowStack.h"

// Local Includes


CShowStack::CShowStack()
	:CCardStack()
{
}

CShowStack::CShowStack(const CPoint& _krPosition, int _iNoOfCardsToShow, int _iOffset, const EStackDirection& _krDirection)
	:CCardStack(_krPosition, _iOffset, _krDirection),
	m_iNoOfCardsToShow(_iNoOfCardsToShow)
{

}


CShowStack::CShowStack(const CShowStack& _krStack)
	:CCardStack(_krStack)
{

}

CShowStack::~CShowStack()
{
}

CPoint CShowStack::VGetNextPosition() const
{
	CPoint currentPosition(m_position);

	for(int i = 0; i <= static_cast<int>(Size() + m_lerpingCards.size()); ++i) {
		if(i <= static_cast<int>(Size() + m_lerpingCards.size() - m_iNoOfCardsToShow + 1) || i == 0) {
		}
		else {
			if(m_eDirection == keDown) {
				currentPosition += CPoint(0, m_iOffset);
			}
			else if(m_eDirection == keRight) {
				currentPosition += CPoint(m_iOffset, 0);
			}
			else if(m_eDirection == keBoth) {
				currentPosition += CPoint(m_iOffset, m_iOffset);
			}
		}
	}

	return currentPosition;
}

void CShowStack::VUpdatePositions()
{
	CPoint currentPosition(m_position);

	for(int i = 0; i < Size(); ++i) {
		if(i <= Size() - m_iNoOfCardsToShow || i == 0) {
			m_cards[i].SetPosition(m_position);
		}
		else {
			if(m_eDirection == keDown) {
				currentPosition += CPoint(0, m_iOffset);
			}
			else if(m_eDirection == keRight) {
				currentPosition += CPoint(m_iOffset, 0);
			}
			else if(m_eDirection == keBoth) {
				currentPosition += CPoint(m_iOffset, m_iOffset);
			}

			m_cards[i].SetPosition(currentPosition);
		}
	}
}

void CShowStack::SetNoOfCardsToShow(int _iNoOfCardsToShow)
{
	m_iNoOfCardsToShow = _iNoOfCardsToShow;
}